$(document).ready(function () {
    selectWarning()
    selectWarningCondition()
});
//无条件查询学业警示
function selectWarning() {
        var table = $('#dataTable').dataTable()
        if (table) {
            table.fnDestroy();
        }
        $('#dataTable').dataTable({
            "bDeferRender": true,
            "sAjaxDataProp": "data.warningList",
            "sAjaxSource": "http://localhost:8080/warning/studentWarning?stuInfoId=" + 1,
            "sPaginationType": "bs_full", //"bs_normal", "bs_two_button", "bs_four_button", "bs_full"
            "fnPreDrawCallback": function (oSettings) {
                $('.dataTables_filter input').addClass('form-control input-large').attr('placeholder', 'Search');
                $('.dataTables_length select').addClass('form-control input-small');
            },
            "oLanguage": {
                "sSearch": "",
                "sLengthMenu": "<span>_MENU_ entries</span>",
                "sZeroRecords": "您好。您暂未收到任何学业警示信息！",
            },
            "bJQueryUI": false,
            "bAutoWidth": false,
            "sDom": "<'row'<'col-lg-6 col-md-6 col-sm-12 text-center'l><'col-lg-6 col-md-6 col-sm-12 text-center'f>r>t<'row-'<'col-lg-6 col-md-6 col-sm-12'i><'col-lg-6 col-md-6 col-sm-12'p>>",
            "aoColumnDefs": [
                {
                    "mDataProp": null,
                    "sDefaultContent": "",
                    "aTargets": [-1]
                }
            ],
            "aoColumns": [
                {"mDataProp": "stuNum"},
                {"mDataProp": "stuName"},
                {"mDataProp": "termYear"},
                {"mDataProp": "termNum"},
                {"mDataProp": "warningNum"},
            ],
        })
}
//条件查询学业警示
function selectWarningCondition() {
    $(document).on('click', '#selectWarning', function () {
        var termYear = $("#termYear option:selected").val();
        var termNum = $("#termNum option:selected").val();
        var url = "http://localhost:8080/warning/studentWarning?stuInfoId=" + 1 + "&termYear=" + termYear + "&termNum=" + termNum;
        var table = $('#dataTable').dataTable()
        if (table) {
            table.fnDestroy();
        }
        $('#dataTable').dataTable({
            "bDeferRender": true,
            "sAjaxDataProp": "data.warningList",
            "sAjaxSource": url,
            "sPaginationType": "bs_full", //"bs_normal", "bs_two_button", "bs_four_button", "bs_full"
            "fnPreDrawCallback": function (oSettings) {
                $('.dataTables_filter input').addClass('form-control input-large').attr('placeholder', 'Search');
                $('.dataTables_length select').addClass('form-control input-small');
            },
            "oLanguage": {
                "sSearch": "",
                "sLengthMenu": "<span>_MENU_ entries</span>",
                "sZeroRecords": "您好。您暂未收到任何学业警示信息！",
            },
            "bJQueryUI": false,
            "bAutoWidth": false,
            "sDom": "<'row'<'col-lg-6 col-md-6 col-sm-12 text-center'l><'col-lg-6 col-md-6 col-sm-12 text-center'f>r>t<'row-'<'col-lg-6 col-md-6 col-sm-12'i><'col-lg-6 col-md-6 col-sm-12'p>>",
            "aoColumnDefs": [
                {
                    "mDataProp": null,
                    "sDefaultContent": "<input type='text' class='studentmark' name='studentmark'/>",
                    "aTargets": [-1]
                }
            ],
            "aoColumns": [
                {"mDataProp": "stuNum"},
                {"mDataProp": "stuName"},
                {"mDataProp": "termYear"},
                {"mDataProp": "termNum"},
                {"mDataProp": "warningNum"},
            ],
        })
    })
}